'''
Created on 5/02/2011

@author: zainul
'''
from MainScreen import RulesObserver
from MainScreen import MainScreen
from Miranda import Rule, RuleSetting, RuleSubject, RuleVerb
import Miranda
import MainScreen
import unittest

class MainScreenTest(unittest.TestCase):


    def setUp(self):
        
        Miranda.CONFIG_FILE_DIR = './resource/'
        Miranda.CONFIG_FILE_NAME = 'main_screen_test.yaml'
            
        
    def testAddRule(self):
        
        main_screen = MainScreen.MainScreen(glade_file='./resource/Main Screen.glade')
               
        rules_observer = RulesObserver(main_screen.rule_list_store);
        
        rule = Rule()
        rule.rule_condition = Miranda.ALL;
        
        rule_setting = RuleSetting();
        rule_setting.description = 'MainScreenTest 1'
        rule_setting.enabled = True;
        rule_setting.source_folder = 'my folder'
        rule.rule_setting = rule_setting;
        
        rules_observer.save_config(rule);
        
        iter = main_screen.rule_list_store.get_iter_first()
        
        self.assertEqual('True', main_screen.rule_list_store.get_value(iter,0));
        self.assertEqual('my folder',MainScreen.rule_dict.keys()[0]);


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'MainScreenTest.testName']
    unittest.main()